package com.ftg.learn.bus.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ftg.learn.bus.entity.BusInfo;
import com.ftg.learn.bus.mapper.BusInfoMapper;
import com.ftg.learn.bus.service.IBusInfoService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.sql.SQLException;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 公车信息表 服务实现类
 * </p>
 *
 * @author lalala
 * @since 2022-03-07
 */
@Service
public class BusInfoServiceImpl extends ServiceImpl<BusInfoMapper, BusInfo> implements IBusInfoService {

    @Resource
    BusInfoMapper busInfoMapper;


    /**
     * 查询所有车的信息及其负责人信息
     */
    @Override
    public List<Map<String, Object>> showBusInfoDirector() {
        return busInfoMapper.showBusInfoDirector();
    }

    /**
     * 简单展示
     * @return
     */
    @Override
    public List<BusInfo> showSimple(Page<BusInfo> infoPage) {
        return busInfoMapper.showSimple(infoPage);
    }


    /**
     * 根据车的信息查询负责人信息
     */
    @Override
    public List<Map<String, Object>> showDirectorForBid(Long bid) {
        return busInfoMapper.showDirectorForBid(bid);
    }

    @Override
    public List<BusInfo> showByBid(Long bid) {
        return busInfoMapper.showByBid(bid);
    }

    @Override
    public List<BusInfo> pageInfoByName(Page<BusInfo> page, Long bid) {
        return busInfoMapper.pageInfoByName(page,bid);
    }
    /**
     * 显示所有负责人
     * @return
     */
    @Override
    public List<Map<String,Object>> showAllDName() {
        return busInfoMapper.showAllDName();
    }

    @Transactional(rollbackFor = SQLException.class)
    @Override
    public boolean updateTimeByBid(Long bid) {
        busInfoMapper.updateTimeByBid(bid);
        return true;
    }
}
